/**
 * 
 */
package com.enjoy.utils;

import com.enjoy.commons.Commons;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class PreferenceHelper {
	public static String getSetting(Context ctx, String key, String defValue) {
		SharedPreferences setting = ctx.getSharedPreferences(Commons.savings,
				Context.MODE_WORLD_READABLE);
		return setting.getString(key, defValue);

	}

	public static boolean addSetting(Context ctx, String key, String value) {
		SharedPreferences setting = ctx.getSharedPreferences(Commons.savings,
				Context.MODE_WORLD_READABLE);
		Editor editor = setting.edit();
		if (setting.contains(key))
			editor.remove(key);
		editor.putString(key, value);
		editor.commit();
		return true;
	}

	public static boolean settingExists(Context ctx, String key) {
		SharedPreferences setting = ctx.getSharedPreferences(Commons.savings,
				Context.MODE_WORLD_READABLE);
		return setting.contains(key);
	}
}
